<h1>New item</h1>
<% javascript 'dynamic_categories' %>

<% form_for(@item) do |f| %>
  <%= f.error_messages %>

  <p>
    <label for="item_category_id">Category:</label>
    <%= f.collection_select :category_id, Category.find(:all), :id, :category_name, {:prompt => "请选择主分类"} %>
  </p>
  <p id="subcategory_field">
    <label for="item_subcategory_id">Sub category:</label>
    <%= f.collection_select :subcategory_id, Subcategory.find(:all), :id, :subcategory_name, {:prompt => "请选择子分类"} %>
  </p>
  <p>
    <%= f.label :item_name %><br />
    <%= f.text_field :item_name %>
  </p>
  <p>
    <%= f.label :brand_name %><br />
    <%= f.collection_select(:brand_id, Brand.find(:all), :id, :brand_name, {:prompt => "请选择品牌"}) %>
    或者,您可以在这里创建一个：<%= f.text_field :new_brand_name %>
  </p>
  <p>
    <%= f.label :item_price %><br />
    <%= f.text_field :item_price %>
  </p>
  <p>
    <%= f.label :item_detail %><br />
    <%= f.text_area :item_detail %>
  </p>
  <p>
    <%= f.label :item_quantity %><br />
    <%= f.text_field :item_quantity %>
  </p>
  <p>
    <%= f.label :item_boughtdate %><br />
    <%= f.date_select :item_boughtdate %>
  </p>
  <p>
    <%= f.label :item_expiredate %><br />
    <%= f.date_select :item_expiredate %>
  </p>
  <p>
    <%= f.submit "Create" %>
  </p>
<% end %>

<%= link_to 'Back', items_path %>
